package com.huiyuanai.service.bill;

import com.huiyuanai.dao.Contact;
import com.huiyuanai.pojo.bill.BillPojo;
import com.huiyuanai.pojo.bill.BillPojoImpl;
import com.huiyuanai.util.BaseUtil;
import org.junit.jupiter.api.Test;

import java.sql.Connection;
import java.util.List;

/**
 * @Author: liwan
 * @Description:
 * @Date: create in 2021/10/18/018
 */
public class BillServiceImpl implements BillService{
    private BillPojo billPojo = null;

    public BillServiceImpl() {
        this.billPojo = new BillPojoImpl();
    }

    @Override
    public List<Contact> getContact(String productName, String ProviderId, int isPayment, int id) throws Exception {
        Connection connection = BaseUtil.getConnectionDIY();
        List<Contact> list = billPojo.getContact(connection, productName, ProviderId, isPayment, id);
        BaseUtil.clostResour(connection, null, null);
        return list;
    }

    @Override
    public int add(Contact contact) throws Exception {
        Connection connection = BaseUtil.getConnectionDIY();
        int result = billPojo.add(connection, contact);
        BaseUtil.clostResour(connection, null, null);
        return result;
    }

    @Override
    public int del(String id) throws Exception {
        Connection connection = BaseUtil.getConnectionDIY();
        int resutl = billPojo.del(connection, id);
        BaseUtil.clostResour(connection, null, null);
        return resutl;
    }

    @Override
    public int upDate(Contact contact) throws Exception {
        Connection connection = BaseUtil.getConnectionDIY();
        int result = billPojo.upDate(connection, contact);
        BaseUtil.clostResour(connection, null, null);
        return result;
    }

    @Test
    public void t() throws Exception {
        BillService billService = new BillServiceImpl();
        List<Contact> contact = billService.getContact(null, null, 0, 0);
        for (Contact contact1 : contact) {
            System.out.println(contact1.getProductName());
        }
    }
}
